<?php

 
// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );

class TableAddon extends HelpDeskTable {

	var $id					= null;
	var $type	  			= null; // varchar(255)
	var $title  			= null; // varchar(255)
	var $description 		= null; // int(11)
	var $filename	 		= null; // int(11)
	var $published	 		= null; // int(11)
	var $order		 		= null; // int(11)
	var $access 			= null; // datetime
	var $iscore 			= null; // tinyint(1)
	var $checked_out 		= null; // varchar(255)
	var $checked_out_time 	= null; // tinyint(1)
	var $version 			= null; // text 	
	var $created_datetime 	= null; // datetime 			
	var $author_name 		= null; // datetime 	
	var $author_email 		= null; // datetime 	
	var $author_url 		= null; // datetime 	

	function TableAddon( &$db ) {
		parent::__construct( '#__helpdesk_addons', 'id', $db );	
	}
	
	/**
	 * 
	 * @return unknown_type
	 */
	function check() 
	{
		/** check for valid name */
		if (trim( $this->title ) == '') {
			$this->_error = HelpDeskText::_( "Title Blank" );
			return false;
		}

		/** check for existing name */
		$query = "SELECT id"
		. "\n FROM #__helpdesk_addons "
		. "\n WHERE `filename` = " . $this->_db->Quote( $this->filename )
		;
		$this->_db->setQuery( $query );

		$xid = intval( $this->_db->loadResult() );
		if ($xid && $xid != intval( $this->id )) 
		{
			$this->_error = HelpDeskText::_( "Addon Exists" );
			return false;
		}

		return true;

	}	
    
}